#pragma once

#include "NiApplication.h"
#include "NtScene.h"

class NtApplication: public NiApplication
{
public:
	NtApplication(void);
	~NtApplication(void);

	virtual BOOL Create(HINSTANCE Instance, 
		unsigned int nWidth, 
		unsigned int nHeight);

	virtual HWND GetHwnd() const;

	virtual HINSTANCE GetAppInstance() const;

	virtual LPDIRECT3DDEVICE9 GetDevice() const;

	static NtApplication* GetInstance();

	NtScenePtr GetScene() { return m_pkScene; }

	void RunLoop();

	void Update(DWORD dwTimer);

	void Render();

	BOOL CreateScene();

	DWORD GetElapseTime() const { return m_dwElapseTime; }

protected:
	void ReleaseApplication();
	BOOL RegisterAppWindow();
	BOOL CreateAppWindow();
	BOOL CreateD3DDevice();
	VOID UpdateTime();
	VOID InitTime();
	static LRESULT CALLBACK MessageProc( HWND hWnd, UINT Id, WPARAM wParam, LPARAM lParam );
	LRESULT OnMessage(HWND hWnd, UINT Id, WPARAM wParam, LPARAM lParam );
protected:
	LPDIRECT3DDEVICE9	m_pDevice;
	HWND				m_hWnd;
	unsigned int		m_nWidth;
	unsigned int		m_nHeight;
	HINSTANCE			m_hInstance;
	std::string			m_AppClassName;
	std::string			m_AppTitle;
	DWORD				m_dwCurrTime;
	DWORD				m_dwLastTime;
	DWORD				m_dwElapseTime;
	BOOL				m_bInitApp;
	NtScenePtr			m_pkScene;
};
